<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="/my-single-spa/lib/umd/single-spa.js"></script>
  <script>
    /**
     * registerApplication的参数
     * 1. 注册应用的名字
     * 2. 加载 app 的方法必须返回一个promise
    */
    singleSpa.registerApplication('app1',
      async () => {
        // 这个必须返回一个结果
        return {
          bootstrap: async () => {
            console.log('bootstrap')
          },
          mount: async () => {
            console.log('mount')
          },
          unmount: async () => {
            console.log('unmount')
          }
        }
      },
      location => location.hash.startsWith('#/app1')
    )
    singleSpa.registerApplication('app2',
      async () => {
        // 这个必须返回一个结果
        return {
          bootsrap: async () => {},
          mount: async () => {},
          unmount: async () => {}
        }
      },
      location => location.hash.startsWith('#/app2')
    )

    // registerApplication 方法默认会加载应用
    singleSpa.start(); // 启动这个应用，start的时候才会挂载
  </script>
</body>
</html>